@echo off
setlocal enabledelayedexpansion

:: 检查是否设置了JAVA_HOME
if not defined JAVA_HOME (
    echo Error: JAVA_HOME environment variable is not set.
    echo Please install JDK 11 or higher and set JAVA_HOME.
    pause
    exit /b 1
)

:: 检查JavaFX路径
if not defined PATH_TO_FX (
    :: 尝试在常见位置查找JavaFX
    if exist "lib\javafx-sdk\lib" (
        set "PATH_TO_FX=lib\javafx-sdk\lib"
    ) else if exist "javafx-sdk\lib" (
        set "PATH_TO_FX=javafx-sdk\lib"
    ) else (
        echo Error: JavaFX SDK not found.
        echo Please set PATH_TO_FX environment variable or place JavaFX SDK in lib\javafx-sdk directory.
        echo Example: set PATH_TO_FX=C:\path\to\javafx-sdk\lib
        pause
        exit /b 1
    )
)

echo Using JavaFX from: %PATH_TO_FX%

:: 编译
echo Compiling VideoPlayer.java...
"%JAVA_HOME%\bin\javac" --module-path "%PATH_TO_FX%" --add-modules javafx.controls,javafx.media VideoPlayer.java
if errorlevel 1 (
    echo Compilation failed.
    pause
    exit /b 1
)

:: 运行
echo Starting Video Player...
"%JAVA_HOME%\bin\java" --module-path "%PATH_TO_FX%" --add-modules javafx.controls,javafx.media VideoPlayer
pause 